import java.util.Scanner;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: 强仔
 * Date: 2022-05-22
 * Time: 16:39
 */
public class Main {
    /*
    * 排序子序列
    * 动态规划
    * https://www.nowcoder.com/questionTerminal/2d3f6ddd82da445d804c95db22dcc471?orderByHotValue=1&page=1&onlyReference=false
    *
    * */
    public static void main1(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();
        long[] arrays = new long[n];
        for (int i = 0; i < n; i++) {
            arrays[i] = scanner.nextInt();
        }

        int[] F = new int[n];

        // 0 --> 表示最后一段子序列长度为1或均相同； 1 --> 表示最后一段子序列非递减； 2 --> 表示最后一段子序列非递增
        int[] book = new int[n];

        F[0] = 1;
        for (int i = 1; i < n; i++) {
            if (book[i - 1] == 0) {
                F[i] = F[i - 1];
                if (arrays[i] != arrays[i - 1]) {
                    book[i] = arrays[i] > arrays[i - 1] ? 1 : 2;
                }
            } else {
                if ((arrays[i] >= arrays[i - 1] && book[i - 1] == 1) || (arrays[i] <= arrays[i - 1] && book[i - 1] == 2)) {
                    F[i] = F[i - 1];
                    book[i] = book[i - 1];
                } else {
                    F[i] = F[i - 1] + 1;
                }
            }
        }
        System.out.println(F[n - 1]);
    }

    /*
    * 排序子序列
    *
    * */
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();
        long[] arrays = new long[n];
        for (int i = 0; i < n; i++) {
            arrays[i] = scanner.nextInt();
        }
        System.out.println(fun(arrays, n));
    }
    public static int fun(long[] array, int n){
        int count = 1;
        for (int i = 1; i < n; i++) {
            // 进入 非递减序列
            if(array[i] > array[i - 1]){
                while(i < n && array[i] >= array[i - 1]){
                    i++;
                }
                if(i < n) {
                    count++;
                }
            } else if(array[i] < array[i - 1]){
                while(i < n && array[i] <= array[i - 1]){
                    i++;
                }
                if(i < n) {
                    count++;
                }
            }
        }

        return count ;
    }


    /*
    * 倒置字符串
    * https://www.nowcoder.com/practice/ee5de2e7c45a46a090c1ced2fdc62355?tpId=85&&tqId=29867&rp=1&ru=/activity/oj&qru=/ta/2017test/question-ranking
    *
    * */

    public static void main2(String[] args) {
        Scanner scanner = new Scanner(System.in);
        String str = scanner.nextLine();
        String[] strings = str.split(" ");
        StringBuilder result = new StringBuilder();
        for (int i = strings.length - 1; i >= 0; i--) {
            result.append(strings[i]);
            result.append(" ");
        }
        System.out.println(result);
    }
}
